<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多彩主题背景切换器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', sans-serif;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
            overflow: hidden;
        }

        /* 多种主题背景 */
        .theme-sunset {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .theme-ocean {
            background: linear-gradient(135deg, #2196F3 0%, #00BCD4 100%);
        }

        .theme-forest {
            background: linear-gradient(135deg, #4CAF50 0%, #8BC34A 100%);
        }

        .theme-fire {
            background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
        }

        .theme-purple {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .theme-dark {
            background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        }

        .theme-pink {
            background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
        }

        .theme-gold {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        .theme-cool {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        .theme-warm {
            background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
        }

        /* 动态粒子背景 */
        .particles {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            z-index: 1;
        }

        .particle {
            position: absolute;
            border-radius: 50%;
            opacity: 0.6;
            animation: float 15s infinite;
        }

        @keyframes float {
            0%, 100% {
                transform: translateY(0px) rotate(0deg);
                opacity: 0.6;
            }
            50% {
                transform: translateY(-20px) rotate(180deg);
                opacity: 1;
            }
        }

        /* 主内容区域 */
        .main-content {
            text-align: center;
            z-index: 10;
            position: relative;
        }

        .title {
            font-size: 3rem;
            font-weight: bold;
            color: white;
            margin-bottom: 1rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
            animation: fadeInUp 1s ease-out;
        }

        .subtitle {
            font-size: 1.2rem;
            color: rgba(255, 255, 255, 0.9);
            margin-bottom: 3rem;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
            animation: fadeInUp 1s ease-out 0.3s both;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* 主题选择器 */
        .theme-selector {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 1rem;
            max-width: 800px;
            margin: 0 auto;
        }

        .theme-btn {
            padding: 1rem;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            background: rgba(255, 255, 255, 0.1);
            color: white;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
            position: relative;
            overflow: hidden;
        }

        .theme-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: left 0.5s;
        }

        .theme-btn:hover::before {
            left: 100%;
        }

        .theme-btn:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            border-color: rgba(255, 255, 255, 0.6);
        }

        .theme-btn.active {
            border-color: white;
            background: rgba(255, 255, 255, 0.2);
            transform: scale(1.05);
        }

        /* 控制面板 */
        .control-panel {
            margin-top: 2rem;
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            justify-content: center;
        }

        .control-btn {
            padding: 0.8rem 1.5rem;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 25px;
            background: rgba(255, 255, 255, 0.1);
            color: white;
            font-size: 0.9rem;
            cursor: pointer;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .control-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        /* 随机主题按钮 */
        .random-btn {
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            border: none;
            font-weight: bold;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.05);
            }
            100% {
                transform: scale(1);
            }
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .title {
                font-size: 2rem;
            }
            
            .subtitle {
                font-size: 1rem;
            }
            
            .theme-selector {
                grid-template-columns: repeat(2, 1fr);
                gap: 0.8rem;
            }
            
            .theme-btn {
                padding: 0.8rem;
                font-size: 0.9rem;
            }
        }

        /* 主题预览 */
        .theme-preview {
            position: fixed;
            top: 20px;
            right: 20px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 1rem;
            color: white;
            font-size: 0.9rem;
            z-index: 100;
        }

        .color-indicator {
            display: inline-block;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin-left: 10px;
            vertical-align: middle;
            border: 2px solid white;
        }
    </style>
</head>
<body class="theme-sunset">
    <!-- 粒子背景 -->
    <div class="particles" id="particles"></div>

    <!-- 主内容 -->
    <div class="main-content">
        <h1 class="title">🎨 多彩主题切换器</h1>
        <p class="subtitle">选择你喜欢的主题背景，让页面焕然一新！</p>
        
        <!-- 主题选择器 -->
        <div class="theme-selector">
            <button class="theme-btn active" data-theme="sunset">🌅 日落</button>
            <button class="theme-btn" data-theme="ocean">🌊 海洋</button>
            <button class="theme-btn" data-theme="forest">🌲 森林</button>
            <button class="theme-btn" data-theme="fire">🔥 火焰</button>
            <button class="theme-btn" data-theme="purple">💜 紫色</button>
            <button class="theme-btn" data-theme="dark">🌙 暗黑</button>
            <button class="theme-btn" data-theme="pink">🌸 粉色</button>
            <button class="theme-btn" data-theme="gold">✨ 金色</button>
            <button class="theme-btn" data-theme="cool">❄️ 清凉</button>
            <button class="theme-btn" data-theme="warm">🌞 温暖</button>
        </div>

        <!-- 控制面板 -->
        <div class="control-panel">
            <button class="control-btn random-btn" id="randomTheme">🎲 随机主题</button>
            <button class="control-btn" id="toggleParticles">✨ 切换粒子</button>
            <button class="control-btn" id="autoSwitch">⏰ 自动切换</button>
        </div>
    </div>

    <!-- 主题预览 -->
    <div class="theme-preview">
        当前主题: <span id="currentTheme">日落</span>
        <span class="color-indicator" id="colorIndicator"></span>
    </div>

    <script>
        // 主题配置
        const themes = {
            sunset: { name: '日落', color: '#667eea' },
            ocean: { name: '海洋', color: '#2196F3' },
            forest: { name: '森林', color: '#4CAF50' },
            fire: { name: '火焰', color: '#FF6B6B' },
            purple: { name: '紫色', color: '#667eea' },
            dark: { name: '暗黑', color: '#2c3e50' },
            pink: { name: '粉色', color: '#ff9a9e' },
            gold: { name: '金色', color: '#f093fb' },
            cool: { name: '清凉', color: '#4facfe' },
            warm: { name: '温暖', color: '#fa709a' }
        };

        let currentTheme = 'sunset';
        let particlesEnabled = true;
        let autoSwitchEnabled = false;
        let autoSwitchInterval;

        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            createParticles();
            setupEventListeners();
            updateThemeDisplay();
        });

        // 创建粒子背景
        function createParticles() {
            const particlesContainer = document.getElementById('particles');
            particlesContainer.innerHTML = '';
            
            for (let i = 0; i < 50; i++) {
                const particle = document.createElement('div');
                particle.className = 'particle';
                
                // 随机属性
                const size = Math.random() * 4 + 2;
                const posX = Math.random() * 100;
                const posY = Math.random() * 100;
                const delay = Math.random() * 15;
                const duration = 10 + Math.random() * 10;
                const color = `rgba(255, 255, 255, ${Math.random() * 0.5 + 0.1})`;
                
                particle.style.width = `${size}px`;
                particle.style.height = `${size}px`;
                particle.style.left = `${posX}%`;
                particle.style.top = `${posY}%`;
                particle.style.background = color;
                particle.style.animationDelay = `${delay}s`;
                particle.style.animationDuration = `${duration}s`;
                
                particlesContainer.appendChild(particle);
            }
        }

        // 设置事件监听器
        function setupEventListeners() {
            // 主题按钮点击事件
            document.querySelectorAll('.theme-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const theme = this.dataset.theme;
                    switchTheme(theme);
                });
            });

            // 随机主题按钮
            document.getElementById('randomTheme').addEventListener('click', function() {
                const themeKeys = Object.keys(themes);
                const randomTheme = themeKeys[Math.floor(Math.random() * themeKeys.length)];
                switchTheme(randomTheme);
                
                // 添加动画效果
                this.style.transform = 'rotate(360deg)';
                setTimeout(() => {
                    this.style.transform = 'rotate(0deg)';
                }, 300);
            });

            // 切换粒子效果
            document.getElementById('toggleParticles').addEventListener('click', function() {
                particlesEnabled = !particlesEnabled;
                const particles = document.getElementById('particles');
                
                if (particlesEnabled) {
                    particles.style.display = 'block';
                    this.textContent = '✨ 关闭粒子';
                } else {
                    particles.style.display = 'none';
                    this.textContent = '✨ 开启粒子';
                }
            });

            // 自动切换
            document.getElementById('autoSwitch').addEventListener('click', function() {
                autoSwitchEnabled = !autoSwitchEnabled;
                
                if (autoSwitchEnabled) {
                    this.textContent = '⏰ 停止切换';
                    this.style.background = 'rgba(255, 107, 107, 0.3)';
                    
                    // 每3秒切换一次主题
                    autoSwitchInterval = setInterval(() => {
                        const themeKeys = Object.keys(themes);
                        const currentIndex = themeKeys.indexOf(currentTheme);
                        const nextIndex = (currentIndex + 1) % themeKeys.length;
                        switchTheme(themeKeys[nextIndex]);
                    }, 3000);
                } else {
                    this.textContent = '⏰ 自动切换';
                    this.style.background = 'rgba(255, 255, 255, 0.1)';
                    clearInterval(autoSwitchInterval);
                }
            });
        }

        // 切换主题
        function switchTheme(theme) {
            if (!themes[theme]) return;
            
            // 移除当前主题类
            document.body.className = '';
            
            // 添加新主题类
            document.body.classList.add(`theme-${theme}`);
            
            // 更新当前主题
            currentTheme = theme;
            
            // 更新按钮状态
            document.querySelectorAll('.theme-btn').forEach(btn => {
                btn.classList.remove('active');
                if (btn.dataset.theme === theme) {
                    btn.classList.add('active');
                }
            });
            
            // 更新显示
            updateThemeDisplay();
            
            // 重新创建粒子
            if (particlesEnabled) {
                createParticles();
            }
        }

        // 更新主题显示
        function updateThemeDisplay() {
            const themeInfo = themes[currentTheme];
            document.getElementById('currentTheme').textContent = themeInfo.name;
            document.getElementById('colorIndicator').style.background = themeInfo.color;
        }

        // 键盘快捷键
        document.addEventListener('keydown', function(e) {
            if (e.key === ' ') {
                e.preventDefault();
                document.getElementById('randomTheme').click();
            } else if (e.key === 'p' || e.key === 'P') {
                document.getElementById('toggleParticles').click();
            } else if (e.key === 'a' || e.key === 'A') {
                document.getElementById('autoSwitch').click();
            }
        });

        // 添加页面加载动画
        window.addEventListener('load', function() {
            document.body.style.opacity = '0';
            document.body.style.transition = 'opacity 1s ease-in-out';
            
            setTimeout(() => {
                document.body.style.opacity = '1';
            }, 100);
        });

        // 添加鼠标移动视差效果
        document.addEventListener('mousemove', function(e) {
            const particles = document.querySelectorAll('.particle');
            const mouseX = e.clientX / window.innerWidth;
            const mouseY = e.clientY / window.innerHeight;
            
            particles.forEach((particle, index) => {
                const speed = (index + 1) * 0.5;
                const x = (mouseX - 0.5) * speed;
                const y = (mouseY - 0.5) * speed;
                
                particle.style.transform = `translate(${x}px, ${y}px)`;
            });
        });
    </script>
</body>
</html>